﻿using System;
using Newtonsoft.Json;

namespace Wala.Connection.Objects.Authen
{
    public class RetAuthen
    {        
        #region //---------- Private Fields -----------//

        private UserLogin _user;        
        private LoginServer _server;        

        #endregion

        #region //---------- CLR Properties ----------//

        public UserLogin User
        {
            get { return _user; }
            set { _user = value; }
        }

        public LoginServer Server
        {
            get { return _server; }
            set { _server = value; }
        }

        #endregion

        #region //---------- Public Constructor ---------//

        public RetAuthen()            
        {
            _server = new LoginServer();
            _user = new UserLogin();
        }

        public RetAuthen(UserLogin _user,LoginServer _server)
        {
            this._server = _server;
            this._user = _user;
        }

        #endregion

        #region //---------- Public Methods -------------//

        public static RetAuthen FromJson(string json)
        {
            try
            {
                RetAuthen retAuthen = JsonConvert.DeserializeObject<RetAuthen>(json);
                return retAuthen;
            }
            catch (Exception ex)
            {
                return null;
            }
        }
        #endregion
    }
}
